﻿using System;
using System.Collections.Generic;
using System.Linq;


namespace btmerc.API.Schemas
{
    public class Eras
    {
        private List<Era> _eraList = new List<Era>();
        public Interfaces.IEra GetEra(string name)
        {
            return _eraList.Where(c => c.Name == name).FirstOrDefault();
        }

        public Interfaces.IEra GetEra(ushort year)
        {
            return _eraList.Where(c => c.StartYear <= year && c.EndYear >= year).FirstOrDefault();
        }

        internal void AddEra(Era era)
        {
            if (GetEra(era.Name) == null)
            {
                _eraList.Add(era);
            }
            else
            {
                throw new ArgumentException(era.Name + " was already added to the era list");
            }
        }
    }
}
